import MetaUtils from "@/utils/MetaUtils";
import {
    editLayoutMetas, drawerMetas, formCommonMetas, operaMetas,
    formLayoutMetas, sliderMetas,
    inputMetas, optionsDataMetas, numberMetas, rateMetas, switchMetas,
    areaMetas, dateMetas, selectMetas, searchFormMetas, modalBasicMetas, modalLayoutMetas, modalOtherMetas, labelMetas
} from "@/metas/ComponentMetas";
import Utils from "@/utils/basic.utils";
const basicLabel = '基础配置', formLabel = "表单配置", layoutLabel = "布局配置"
const DrawerEditTabMetas = {
    basic: {label: basicLabel, metas: [...drawerMetas, ...editLayoutMetas]}
}
const ModalEditTabMetas = {
    basic: {label: basicLabel, metas: [...modalBasicMetas, ...editLayoutMetas]},
    form: {label: formLabel, metas: [...modalOtherMetas]},
    layout: {label: layoutLabel, metas: [...modalLayoutMetas]}
}

const LabelTabMetas = {
    basic: {label: basicLabel, metas: [...labelMetas]}
}

const TextTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...inputMetas, ...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const PasswordTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const SelectTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...selectMetas, ...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const RadioTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const RateTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [ ...rateMetas, ...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const DateTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...dateMetas, ...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const SwitchTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...switchMetas, ...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const TextareaTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...areaMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const CheckboxTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const NumberTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...numberMetas, ...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const SliderTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...sliderMetas, ...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const TreeTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const UploadTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const CascadeTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const StreeTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const FormTabMetas = {
    TextTabMetas, NumberTabMetas, SelectTabMetas, LabelTabMetas
    , RadioTabMetas, CascadeTabMetas, CheckboxTabMetas, StreeTabMetas
    , SliderTabMetas, UploadTabMetas, TreeTabMetas, TextareaTabMetas, SwitchTabMetas
    , DateTabMetas, RateTabMetas, PasswordTabMetas
}

function getFormTabMetas(type) {
    type = Utils.firstUpperCase(type) + 'TabMetas';
    let formTabMeta = FormTabMetas[type];
    if(null == formTabMeta) {
        throw new Error(`找不到类型[${type}]对应的TabMetas对象`)
    }
    return MetaUtils.cloneTabMetas(formTabMeta);
}

export {getFormTabMetas, DrawerEditTabMetas, FormTabMetas, ModalEditTabMetas}
